﻿using Mengsk.ProxyDelivery.Domain;
using Mengsk.ProxyDelivery.Service;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Data;

namespace Mengsk.ProxyDelivery.Converters
{
    public class SellerMoneyConverter : IValueConverter
    {
        private SellerMoneyService sellerMoneyService = ServiceContainer.GetService<SellerMoneyService>();

        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            if (value == null || value.GetType() != typeof(int))
            {
                return value;
            }

            int id = (int)value;
            SellerMoney sm = this.sellerMoneyService.GetById(id);
            if (sm != null)
            {
                return sm.Money.ToString("F2");
            }
            return "";
        }

        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }
}
